﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GIMP
{
    public partial class SelecionaImagens : Form
    {
        List<int> checkedIndices = null;

        public SelecionaImagens(List<ImagemZoom> imagens)
        {
            InitializeComponent();
            foreach (ImagemZoom i in imagens)
                this.checkedListBox1.Items.Insert(this.checkedListBox1.Items.Count, i.Name);
        }

        private void AbilitaBotaoAplicar(object sender, ItemCheckEventArgs e)
        {
            if (e.CurrentValue == CheckState.Checked && this.checkedListBox1.CheckedIndices.Count < 2)
            {
                if (this.botao_aplicar.Enabled)
                {
                    this.botao_aplicar.Enabled = false;
                }
            }
            else
            {
                if (!this.botao_aplicar.Enabled)
                {
                    this.botao_aplicar.Enabled = true;
                }
            }
        }

        public List<int> CheckedIndices
        {
            get
            {
                return this.checkedIndices;
            }
        }

        private void GenerateListChecked(object sender, EventArgs e)
        {
            if (this.botao_aplicar.Enabled)
            {
                this.checkedIndices = new List<int>();
                foreach (int i in this.checkedListBox1.CheckedIndices)
                    this.checkedIndices.Add(i);
            }
        }
    }
}
